package db

import (
	"fmt"
	"gorm.io/driver/postgres"
	"gorm.io/gorm"
)

type PostgreSQLConfig struct {
	Host     string
	Port     string
	Database string
	Username string
	Password string
	Charset  string
}

func (c *PostgreSQLConfig) connect() *gorm.DB {
	connectString := fmt.Sprintf("host=%s port=%s user=%s dbname=%s password=%s", c.Host, c.Port, c.Username, c.Database, c.Password)
	db, err := gorm.Open(postgres.Open(connectString), &gorm.Config{})
	if err != nil {
		panic(err)
	}

	return db
}
